import head from '~/config/head';
export default option => {
  let {
    name,
    unHead,
  } = option;

  if (!option.head && !unHead && name) {
    let nameSave = name;
    option.head = () => {
      let {
        title,
        meta,
      } = head(nameSave);
      return {
        title,
        meta,
      };
    };
  }
  if (typeof name !== 'undefined') {
    if (!option.data) option.data = {};
    option.data.window = head(name);
    name = name.toUpperCase();
  }
  if (typeof option.methods !== 'undefined') {
    option.methods['WINDOW'] = cb => {
      if (process.browser) {
        cb(window);
      }
    };
  }
};
